home *** CD-ROM | disk | FTP | other *** search
-
- COMMENT^ ** SETPRN.COM ** Last Rev. 12/11/83 ** Vincent T. Bly **
- -------------------------------------------------------------------
- | |
- | PURPOSE: Provide a easy method of setting printer parameters |
- | from the DOS command level or from a batch file. |
- | |
- | FUNCTION: Send a user specified text string to the printer. |
- | The string may contain control characters consisting |
- | of decimal numbers enclosed in brackets ("[" and "]"). |
- | The normal ending carriage return/line feed may be |
- | suppressed by a trailing semicolon (";") or comma (",") |
- | in the same manner as the BASIC LPRINT command. |
- | |
- | TO USE: From DOS, type SETPRN followed by a space and the text |
- | string, then press <enter>. For examples, see the file |
- | SETPRN.DOC |
- | |
- -------------------------------------------------------------------^
-
- CSEG SEGMENT
- ASSUME CS:CSEG,DS:CSEG
-
- ORG 80H ;----------- in Program Segment Prefix
- NUM_CHARS LABEL BYTE ;number of characters in argument
- ORG 82H
- ARGTX LABEL BYTE ;start of text (after leading blank)
-
- ORG 100H ;---------- start of actual program
-
- ;~~ Check argument & set-up to read it ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- START: MOV BX,OFFSET ARGTX ;point to start of text argument
- MOV CL,[NUM_CHARS] ;set CX to number of chars in argument
- MOV CH,0 ; "
- CMP CX,2 ;is there at least 1 char after blank?
- JB CR_LF1 ;if not, print CR/LF & exit
- SUB CX,2 ;discount char count for leading blank
- ;and possible trailing "," or ";"
- CMP CX,0 ;is there only one character?
- JE TERM ;if so, handle w/termination routine
-
- ;~~~ Parse argument & convert control codes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CHAR_2_PRN: MOV DL,[BX] ;get character
- CMP DL,'[' ;is it the control prefix char?
- JNE SEND_IT ;if not, go print char
- MOV AL,0 ;initialize char value to 0
- MOV DH,10D ;digit multiplier
- CONVERT_DIGIT: INC BX ;skip to next char
- DEC CX ; "
- MOV DL,[BX] ;get char code into DL
- JZ EXIT2 ;exit if at end of text (CX = 0)
- CMP DL,']' ;is it the control code suffix?
- JE PRE_SEND_IT ;if so, go prepare to print code
- SUB DL,'0' ;convert digit code to value
- MUL DH ;mult. char value (in AL) by 10
- ADD AL,DL ;add digit value to char value
- JMP CONVERT_DIGIT ;loop back to convert next digit
- PRE_SEND_IT: MOV DL,AL ;put converted code into DL
-
- ;~~~ Send character to printer & loop back for next ~~~~~~~~~~~~~~~~~~~~~~~~~
- SEND_IT: CALL PRNT_CHR ;go print character in DL
- INC BX ;point to next character
- LOOP CHAR_2_PRN ;repeat until done
-
- ;~~~ Handle termination with ";" or "," ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- TERM: MOV DL,[BX] ;get last character
- CMP DL,';' ;is it a semicolon?
- JE COMPLETE ;if so, skip to completion routine
- CMP DL,',' ;is it a comma?
- JNE CR_LF ;if not, go print CR & LF
- MOV DL,09 ;set DL to tab character
- CALL PRNT_CHR ;go print tab
- JMP COMPLETE ;skip to completion routine
- CR_LF: CALL PRNT_CHR ;go print last character
- CR_LF1: MOV DL,0DH ;set DL to carriage return
- CALL PRNT_CHR ;go print CR
- MOV DL,0AH ;set DL to line feed
- CALL PRNT_CHR ;go print LF
-
- ;~~~ Display termination message & return to DOS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- COMPLETE: MOV DX,OFFSET MESSAGE ;point to completion message
- MOV AH,9 ;code for DOS display string function
- INT 21H ;display message via DOS function call
- EXIT1: INT 20H ;terminate via DOS function call
- MESSAGE: DB '* Done *$'
-
- ;~~~ Send one character to printer via DOS function call ~~~~~~~~~~~~~~~~~~~~~
- PRNT_CHR: MOV AH,5 ;code for DOS printer output function
- INT 21H ;send to printer via DOS function call
- RET ;back to calling routine
-
- ;~~~ Handle case where end of text encountered while parsing control code ~~~~
- EXIT2: CMP DL,']' ;is it the control code suffix?
- JNE TERM ;if not, go do normal completion
- ;(w/o printing control code)
- MOV DL,AL ;put control code in DL
- CALL PRNT_CHR ;go print control code
- JMP CR_LF ;go print CR & LF & complete
-
- CSEG ENDS
-
- END START